package com.k2091.washcar.controller;


import com.k2091.washcar.entity.FormInline;
import com.k2091.washcar.entity.ServiceItem;
import com.k2091.washcar.entity.Users;
import com.k2091.washcar.service.IServiceItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.FileCopyUtils;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author author
 * @since 2021-06-01
 */
@RestController
@RequestMapping("/api/service")
public class ServiceItemController {

    @Autowired
    private IServiceItemService iServiceItemService;

    @RequestMapping("/addService")
    @ResponseBody
    public void addService(ServiceItem serviceItem){
        if (iServiceItemService.selectServiceById(serviceItem.getId())!=null){
            iServiceItemService.upProject(serviceItem);
        }else {
            iServiceItemService.addService(serviceItem);
        }
    }

    @RequestMapping(value = "/upStatus",method = RequestMethod.GET)
    @ResponseBody
    public void upStatus(Long id,int status,String token){
        iServiceItemService.upStatus(id, status);
    }

    @RequestMapping(value = "/deleteService")
    @ResponseBody
    public void deleteUser(Long id,String token){
        iServiceItemService.ServiceDelete(id);
    }

    @RequestMapping("/getServiceList")
    @ResponseBody
    public List<ServiceItem> serviceItems(FormInline formInline){
        return iServiceItemService.selectProject(formInline);
    }

}
